Skip to content

fix(waterdata): small coherence cleanups (annotations, column order, defensiveness)#306

Merged
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/waterdata-small-cleanups
Jun 1, 2026
Merged

fix(waterdata): small coherence cleanups (annotations, column order, defensiveness)#306
thodson-usgs merged 1 commit into
DOI-USGS:mainfrom
thodson-usgs:fix/waterdata-small-cleanups

Conversation

@thodson-usgs

Copy link
Copy Markdown
Collaborator

Summary

Five small, low-risk cleanups from the package review — annotation drift, a cosmetic column-order inconsistency, and two latent defensive fixes.

  1. value annotation (get_latest_continuous, get_latest_daily): was int, but every other getter and the docstrings use str | Iterable[str]. The int hint also rejected the multi-value list filtering the siblings advertise.
  2. thresholds annotation (get_time_series_metadata): was int, vs float | list[float] on get_combined_metadata for the same queryable.
  3. _arrange_cols (cosmetic): the set that moves the synthetic per-record id column to the end omitted peak_id, channel_measurements_id, combined_meta_id, field_series_id — so those four getters left their id at the front, unlike daily_id/continuous_id. Added them so column layout is consistent across the parallel getters.
  4. _next_req_url: returned a falsy href ("") instead of None, contradicting its Optional[str] contract (live callers mask it with or None, so this is hardening rather than a live bug).
  5. _get_resp_data (geopandas branch): pd.json_normalize(features)["id"] raises KeyError if a feature lacks a top-level id; the non-geopandas branch already uses the defensive f.get("id"). Mirrored it.

Verification (live API)

  • get_peaks(...)peak_id is now the last column (was at the front); 11 affected getter tests pass live.
  • The annotation changes (1, 2) are type-hint only — runtime is unchanged. ruff clean.

🤖 Generated with Claude Code

…defensiveness)

Five small, low-risk fixes surfaced by the package review:

1. get_latest_continuous / get_latest_daily: `value` was annotated `int`, but
   every other getter (and the docstrings) use `str | Iterable[str]`; the `int`
   hint also rejected the multi-value list filtering the others advertise.
2. get_time_series_metadata: `thresholds` was annotated `int`, vs
   `float | list[float]` on get_combined_metadata for the same queryable.
3. _arrange_cols: the "move the synthetic per-record id column to the end" set
   was a hand-maintained literal that omitted peak_id, channel_measurements_id,
   combined_meta_id, and field_series_id, so those four getters left their id at
   the front instead of the end like daily_id. Derive the set from
   _OUTPUT_ID_BY_SERVICE (every output id except the user-facing
   monitoring_location_id and time_series_id) so it stays in sync and can't
   drift again when a service is added.
4. _next_req_url: returned a falsy `href` ("") instead of None, contradicting
   its Optional[str] contract. Return None.
5. _get_resp_data (geopandas branch): mirror the non-geopandas branch's
   `f.get("id")` so a feature missing a top-level id yields None rather than a
   KeyError.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thodson-usgs thodson-usgs force-pushed the fix/waterdata-small-cleanups branch from 9e05040 to 910522f Compare May 31, 2026 22:09
@thodson-usgs thodson-usgs marked this pull request as ready for review June 1, 2026 00:55
@thodson-usgs thodson-usgs merged commit 665383f into DOI-USGS:main Jun 1, 2026
8 checks passed
@thodson-usgs thodson-usgs deleted the fix/waterdata-small-cleanups branch June 1, 2026 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant